package com.yequan.designpattern.observer.wechat;

/**
 * 观察者实例
 *
 * @author yequan
 * @date 2019/12/12
 */
public class User implements Observer {

    /**
     * 用户名
     */
    private String name;

    /**
     * 接收的消息
     */
    private String message;

    public User(String name) {
        this.name = name;
    }

    @Override
    public void update(String message) {
        this.message = message;
        read();
    }

    /**
     * 读取消息
     */
    public void read() {
        System.out.println("用户" + name + "收到推送消息: " + message);
    }
}
